---
title: DataRecordsets.GetLastDataError Method (Visio)
keywords: vis_sdr.chm16360615
f1_keywords:
- vis_sdr.chm16360615
ms.prod: visio
api_name:
- Visio.DataRecordsets.GetLastDataError
ms.assetid: c3c4490f-a9bb-2f36-6a3d-b3be0a94fa2b
ms.date: 06/08/2017
---


# DataRecordsets.GetLastDataError Method (Visio)

Gets the Active X Data Objects (ADO) error code, ADO description, and data recordset ID associated with an error that results from adding a new data recordset or refreshing the data in an existing one.


 **Note**  This Visio object or member is available only to licensed users of Visio Professional 2013.


## Syntax

 _expression_ . **GetLastDataError**( **_DataErrorCode_** , **_DataErrorDescription_** , **_RecordsetID_** )

 _expression_ An expression that returns a **DataRecordsets** object.


### Parameters



|**Name**|**Required/Optional**|**Data Type**|**Description**|
|:-----|:-----|:-----|:-----|
| _DataErrorCode_|Required| **Long**|Out parameter. The ADO error code of the last error.|
| _DataErrorDescription_|Required| **String**|Out parameter. The ADO description of the last error.|
| _RecordsetID_|Required| **Long**|Out parameter. The ID of the data recordset that generated or triggered the error.|

### Return Value

Nothing


## Remarks

Data-related operations that can generate ADO errors in Microsoft Visio include adding a new  **DataRecordset** object to the **DataRecordsets** collection of the active document and refreshing the data in an existing data recordset.

If a data-related operation is successful, the  **GetLastDataError** method returns RecordsetID = 0, DataErrorCode = 0, and DataErrorDescription = "" (an empty string).

If attempting to add a data recordset generates an error, the method returns RecordsetID = 0, as well as the error code and description.

If attempting to refresh the data in an existing data recordset causes an error, and if Visio knows which data recordset caused the error,  **GetLastDataError** returns the ID of the data recordset.

It is possible, however, that Visio may not know specifically which data recordset generated the error. This can only happen when you attempt to refresh a data recordset that is one of a group of data recordsets that share the same connection to a data source. This is because when data in one data recordset in such a group (called  _transacted_ datarecordsets) is refreshed, all the data recordsets in the group are refreshed. In this situation, if the refresh operation fails before all datarecordsets in the group are refreshed, Visio rolls back the refresh of any datarecordsets succesfulfully completed up to that point.

If you then call  **GetLastDataError** , the method returns the following:


- The ID of the data recordset on which you called the  **Refresh** method to start the refresh operation that subsequently failed.
    
- The error message generated by the failed refresh operation, although there is no way to know if the failure was specifically related to the data recordset whose ID you passed to the  **GetLastDataError** method.
    

## Example

The following Microsoft Visual Basic for Applications (VBA) macro shows how to use the  **GetLastDataError** method to get the ADO error code and description and the data recordset ID associated with the last data error.


```vb
Public Sub GetLastDataError_Example() 
 
    Dim vsoDataRecordsets As Visio.DataRecordsets 
    Dim lngCode As Long 
    Dim strDescription As String 
    Dim lngID As Long 
     
    Set vsoDataRecordsets = Visio.ActiveDocument.DataRecordsets 
     
    vsoDataRecordsets.GetLastDataError lngCode, strDescription, lngID 
     
    Debug.Print "Error code: ", lngCode 
    Debug.Print "Error description: ", strDescription 
    Debug.Print "Data recordset ID: ", lngID 
 
 
End Sub
```


